package com.magic.zhixin.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.magic.zhixin.model.QuestionStatus;
import com.magic.zhixin.model.QuestionType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@Data
@Entity
@ApiModel(value = "用户提问")
public class UserQuestion extends BaseEntity {
    @ApiModelProperty("用户id")
    private Long userId;
    private String nickName;
    private String avatar;
    @ApiModelProperty("问题数量")
    private Integer questionAmount;
    @ApiModelProperty("奖金总额")
    private BigDecimal totalBonus = BigDecimal.ZERO;
    @ApiModelProperty("手续费")
    private BigDecimal fee = BigDecimal.ZERO;
    @ApiModelProperty("奖励个数")
    private Integer rewardAmount = 0;
    @ApiModelProperty("答题人数")
    private Integer answerAmount = 0;
    @ApiModelProperty("中奖人数")
    private Integer prizeAmount = 0;

    @ApiModelProperty("问题类型：红包、奖励、无")
    @Enumerated(EnumType.ORDINAL)
    @Column(columnDefinition = "tinyint(1) NOT NULL")
    private QuestionType questionType;

    @ApiModelProperty("题库id")
    private Long questionBankId;
    @ApiModelProperty("题库名称")
    @Column(columnDefinition = "text")
    private String questionBankName;

    @ApiModelProperty("问题状态 ：提交、失败、成功")
    @Enumerated(EnumType.ORDINAL)
    @Column(columnDefinition = "tinyint(1)")
    private QuestionStatus questionStatus;

    @ApiModelProperty("正确数量")
    private Integer rightAmount = 0;

    private String rightIds;

    private String sn;
    @JsonFormat(shape = JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date expireTime;

    private Integer questionProgress;//0进行中 1已抢光 2已过期

    @Transient
    private List<UserQuestionDetail> questionDetails;
}
